#define _CRT_SECURE_NO_WARNINGS 1

public static int solution(int[] arr) {
    
    Arrays.sort(arr);
    int count = 0;
    int mid = arr.length / 2;
    for (int i = 0; i < arr.length; i++) {
        if (arr[i] == arr[mid]) {
            count++;
        }
    }
    if (count > mid) 
    {
        return arr[mid];
    }
    return 0;
}
